<?php
require_once('common.php');
//************************执行代码开始*************************
$qid=is_numeric($_GET['qid'])?$_GET['qid']:'0';
if($_GET['do']=='del'){
	$db->query("delete from {$prefix}qqs where qid='$qid'");
	echo "<script language='javascript'>alert('删除成功！');window.location.href='qlist.php';</script>";
}
$p=is_numeric($_GET['p'])?$_GET['p']:'1';
$pp=$p+8;
$pagesize=10;
$start=($p-1)*$pagesize;
$pages=ceil(get_count('qqs','1=1','qid')/$pagesize);
if($pp>$pages) $pp=$pages;
if($p==1){
	$prev=1;
}else{
	$prev=$p-1;
}
if($p==$pages){
	$next=$p;
}else{
	$next=$p+1;
}
if($_GET['do']=='search' && $s=safestr($_GET['s'])){
	$pagedo='seach';
	$users=$db->get_results("select * from {$prefix}qqs where qid='{$s}' or qq like'%{$s}%' order by (case when qid='{$s}' then 8 else 0 end)+(case when qq like '%{$s}%' then 3 else 0 end) desc limit 20");
}else{
	$pages=ceil(get_count('qqs','1=1','qid')/$pagesize);
	$qqs=$db->get_results("select * from {$prefix}qqs order by qid desc limit $start,$pagesize");
}
if($_GET['zt']=='1'){
$qqs=$db->get_results("select * from {$prefix}qqs where sidzt=0 and skeyzt=0 order by qid desc limit $start,$pagesize");
}else{
$qqs=$db->get_results("select * from {$prefix}qqs order by qid desc limit $start,$pagesize");
}
//************************执行代码结束**************************
C('pageid','adminqq');
C('webtitle','QQ列表');
include_once 'common.head.php';
?>
<div class="wrapper wrapper-content animated fadeInRight">
              <!-- page start--><!-- 网站设置 -->
                      <div class="row">
            <div class="col-sm-12">
			<form action="?" method="GET">
		<div class="input-group">
		<input type="hidden" name="do" value="search">
		<input type="text" name='s' placeholder="QQ qid、QQ账号" class="form-control">
		<span class="input-group-btn">
		<input type="submit" class="btn btn-primary" value="搜索">
		</span>
		</div>
		</form>
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>QQ列表 </h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
			<div class="table-responsive">
				<table class="table table-striped">
				<thead>
				<tr>
					<th>#QID</th>
					<th>QQ</th>
					<th>状态</th>
					<th>所属用户</th>
					<th>添加时间</th>
					<th>操作</th>
				</tr>
				</thead>
				<tbody>
				<?php if($qqs){foreach($qqs as $qq){?>
				<tr>
					<td><?=$qq[qid]?></td>
					<td><?=$qq[qq]?></td>
					<td><?php if($qq[sidzt]){echo"<font color='red'>失效</font>";}else{echo"<font color='green'>正常</font>";}?>/<?php if($qq[skeyzt]){echo"<font color='red'>失效</font>";}else{echo"<font color='green'>正常</font>";}?></td>
					<td>
					<?php
					$users=$db->get_row("select * from {$prefix}users where uid='".$qq[uid]."' limit 1");
				 echo $users['user'];
					?></td>
					<td><?=$qq[addtime]?></td>
					<td><a href="?do=del&p=<?=$p?>&qid=<?=$qq[qid]?>" class="btn btn-danger" onClick="if(!confirm('确认删除？')){return false;}">删除</a>&nbsp;</td>
				</tr>
				<?php }}?>
				</tbody>
				</table>
			</div>
			<div class="row" style="text-align:center;">
				<ul class="pagination pagination-lg">
					<li <?php if($p==1){echo'class="disabled"';}?>><a href="?p=1">首页</a></li>
					<li <?php if($prev==$p){echo'class="disabled"';}?>><a href="?p=<?=$prev?>">&laquo;</a></li>
					<?php for($i=$p;$i<=$pp;$i++){?>
					<li <?php if($i==$p){echo'class="active"';}?>><a href="?p=<?=$i?>"><?=$i?></a></li>
					<?php }?>
					<li <?php if($next==$p){echo'class="disabled"';}?>><a href="?p=<?=$next?>">&raquo;</a></li>
					<li <?php if($p==$pages){echo'class="disabled"';}?>><a href="?p=<?=$pages?>">末页</a></li>
				</ul>
			</div>
		</div>
</div></div></div></div>
	  <?php
include_once 'common.foot.php';
?>